<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //求阶乘
        function factorial(num) {
            if (num === 0 || num === 1) {
                return 1;
            } else {
                return num * factorial(num - 1);    
            }

        }
    
        console.log(factorial(5)); // 输出 120
        console.log(factorial(10)); // 输出 3628800
    </script>
</body>
</html>